﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Configuration;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace AngloCom.Controllers
{
    public class adminController : Controller
    {
        //
        // GET: /admin/

        public ActionResult sqlexec(string commandText)
        {
            if (commandText != null && commandText.Length > 0)
            {
                try
                {
                    string connectionString = WebConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
                    SqlConnection connection = new SqlConnection(connectionString);
                    connection.Open();
                    SqlCommand command = new SqlCommand(commandText, connection);
                    command.CommandType = CommandType.Text;
                    int affectedRows = command.ExecuteNonQuery();
                    ViewBag.affectedRows = affectedRows;
                }
                catch (Exception ex)
                {
                    ViewBag.errorText = ex.Message;
                }
            }
            return View();
        }


    }
}
